<?php

use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Dcat\Admin\Admin;

Admin::routes();

Route::group([
    'prefix'     => config('admin.route.prefix'),
    'namespace'  => config('admin.route.namespace'),
    'middleware' => config('admin.route.middleware'),
], function (Router $router) {

    $router->get('/', 'HomeController@index');
    //网站配置
    Route::get('/settings/{classinfo}', 'SettingsController@index')->name('settings.index');

    // 客户
    $router->resource('casecustomers', 'CaseCustomerController');

    //更改客户所属销售
    $router->patch('/casecustomers/{customer}/changeUser', 'CaseCustomerController@changeUser')->name('casecustomers.changeUser')->where(['customers' => '[0-9]+']);

    //线索
    $router->resource('caseleads', 'CaseLeadController');

    //分享
    Route::post('/shares/store', 'CaseShareController@shareStore')->name('shares.store');

    //跟进记录
    $router->resource('caseevents', 'CaseEventController');

    //合同
    $router->get('/casecontracts/{id}/nodes', 'CaseContractController@nodes')->name('contracts.nodes')->where(['article' => '[0-9]+']);
    $router->resource('casecontracts', 'CaseContractController');

    //附件
    $router->resource('attachments', 'AttachmentController');

    //联系人
    $router->resource('casecontacts', 'CaseContactController');

    //商机
    $router->resource('caseopportunitys', 'CaseOpportunityController');

    //发票
    $router->patch('/caseinvoices/{invoice}/state', 'CaseInvoiceController@state')->name('invoices.state')->where(['article' => '[0-9]+']);
    $router->resource('caseinvoices', 'CaseInvoiceController');

    //收款
    $router->get('casereceipts/deposit','CaseReceiptController@deposit')
    ->name('receipts.deposit');
    $router->resource('casereceipts', 'CaseReceiptController');

    //产品
    $router->resource('caseproducts', 'CaseProductController');
    Route::get('/caseproductslist', 'CaseProductController@list')->name('products.list');

    //委托
    $router->resource('casebatchs', 'CaseBatchController');

    //案件
    $router->resource('casecases', 'CaseCaseController');

    //更改案件律师
    $router->patch('/casecases/{case}/changeUser', 'CaseCaseController@changeUser')->name('casecases.changeUser')->where(['case' => '[0-9]+']);

    //产品字段
    $router->resource('caseproductfields', 'CaseProductFieldController');

    //字段
    $router->resource('casecustomfields', 'CaseCustomfieldController');

    //合同范本
    $router->resource('modelcontracts', 'CaseModelcontractController');

    //案件进度
    $router->resource('casecaseprogress', 'CaseCaseProgressController');

    // 生成合同
    Route::get('/buildContracts/form', 'BuildContractsController@index')->name('buildContracts.index');
    Route::post('/buildContracts/form', 'BuildContractsController@store');
});
